import { AxiosResponse } from 'axios'
import { LoginFormValues, Token, User, UserProfile } from '../types/data'
import request from '../utils/request'

export const loginApi = (data: LoginFormValues) => {
  // return request({
  //   url: 'authorizations',
  //   method: 'POST',
  //   data,
  // })
  return request.post<AxiosResponse<Token>>('authorizations', data)
}

export const getCodeApi = (mobile: string) => {
  return request({
    url: '/sms/codes/' + mobile,
    method: 'GET',
  })
}
export const getUserApi = () => {
  return request.get<AxiosResponse<User>>('/user')
}
export const getUserProfileApi = () => {
  return request.get<AxiosResponse<UserProfile>>('/user/profile')
}

export const updatatUserProfileApi = (key: string, value: string) => {
  return request.patch('/user/profile', {
    [key]: value,
  })
}
